home *** CD-ROM | disk | FTP | other *** search
- /****i* SOURCE_FILE/INFO
- *
- * NAME
- * Site.js
- *
- * USAGE
- * Part of Netobjects JavaScript Library.
- *
- * COPYRIGHT
- * Copyright ⌐ 2000-2005 Website Pros, Inc.
- * All Rights Reserved.
- *
- * This is an unpublished work protected by Website Pros, Inc.
- * as a trade secret, and is not to be used or disclosed except as
- * expressly provided in a written license agreement executed by
- * you and Website Pros, Inc.
- *
- * <copyright@websitepros.com>
- *
- * NOTES
- * JavaScript code.
- *
- *****/
-
- if (!IS.isModuleInitialized("IS.NOF.Site"))
- {
- /****h* NOF_JavaScript_Library/NOF.Site
- *
- * NAME
- * NOF.Site
- *
- * DESCRIPTION
- *
- * External dependencies: NOF.App, NOF.UTIL.Exception
- ****/
-
- /**
- * Constructor
- */
- function NOF_Site( sitePath ) {
- this.__proto__ = NOF_Site.prototype;
- //try{
- //alert("|" + NOF_Site.caller + "|\r\n");
- //if ( (NOF.Site.caller == NOF.App.getCurrentSite) || (NOF.Site.caller == NOF.App.newSite) || (NOF.Site.caller == NOF.App.openSite) ) {
- this.sitePath = sitePath;
- //} else {
- // throw new NOF.UTIL.Exception("invalid caller");
- //}
- //} catch(cexc) {
- // alert(cexc.description);
- //}
- }
- {
- // declaration member variables and constants
- var member = NOF_Site.prototype;
- member.CLASS_NAME = "NOF.Site";
-
- // declaration member methods
- var method = NOF_Site.prototype;
- /*
- NOF.Site( String path )
- boolean isOpen()
- setVariable(String pName, String pValue)
- string getVariable(String pName [, String altValue])
- String getBaseDirectory()
- NOF.Page getLastOpenedPageName()
- Date getLastModificationDate()
- Date getLastPublishDate()
- int getNumberOfPages()
- NOF.Page getCurrentPage()
- setCurrentPage(NOF.Page page)
- loadPageById( int pageId )
- importSiteSection(NOF.Page parent, String fromPath)
- NOF.Page getHomePage() //returns the home page (root node) of the opened site.
- save() //save the changes
- NOF.Layout getLayout(String pName) // returns a named layout. This should be used for MasterBorders only because they will have unique names.
- getAllComponents() - in the current site
- getCurrentComponent()
- NOF.Page createPage(String pName) // creates a new child page with the specified name (in the current site). The new page is returned.
- NOF.Page deletePage (String pName) // delete page
- */
-
- /**
- * Check if the current site is open.
- *
- * @return true if the specified site is already open
- **/
- method.isOpen = function () {
- return NOF.App.getFSIApp().IsSiteOpen(this.sitePath);
- }
-
- /**
- * Sets the value of a new or existing site specific variable.
- * Site variables are available when the current site is open.
- *
- * @param pName name of the variable
- * @param pValue value of the variable
- **/
- method.setVariable = function (/*String*/ pName, /*String*/ pValue) {
- NOF.App.getFSIApp().SetSiteVar(pName, pValue);
- }
-
- /**
- * Returns the value of a site specific variable. If the variable is not defined
- * the function will return an empty string.
- *
- * @param pName name of the variable
- * @return the value of the pName variable
- **/
- method.getVariable = function (/*String*/ pName) {
- return NOF.App.getFSIApp().GetSiteVar(pName);
- }
-
- /**
- * SetPassword defines a password that can be used within URLs
- * In functions accepting a URL the password can then be specified using the string:
- * %pw_<passwordName>%
- * If the password name is found and the context is valid the string will be replaced by
- * the actual password.
- * The password is available only in the current site.
- *
- * @param passwordName defines a name for the password
- * @param password defines the actual password.
- * @param context specifies the context for the password, which means that
- **/
- method.setPassword = function (/*String*/ passwordName,/*String*/ password,/*String*/ context) {
- NOF.App.getFSIApp2().SetSitePassword(passwordName, password, context );
- }
-
- /**
- * HasPassword verify if a password was defined or not.
- * Passwords are defined using the function setPassword.
- * @param passwordName
- * @return a boolean specifying whether a password with the specified name is defined.
- **/
- method.hasPassword = function (/*String*/ passwordName) {
- return NOF.App.getFSIApp2().HasSitePassword(passwordName);
- }
-
-
-
- /**
- * Get the base directory for the currently open Fusion site.
- *
- * @return the base directory path for the currently open Fusion site.
- **/
- method.getBaseDirectory = function () {
- return NOF.App.getFSIApp().SiteDirectory;
- //return this.sitePath.substring(0, this.sitePath.lastIndexOf("\\"));
- }
-
- /**
- * Get the last opened Page (in Page view).
- *
- * @return the name of the Page
- **/
- method.getLastOpenedPageName = function () {
- var infoStr = this.getSiteInformation();
- var tmpArr = infoStr.split(",");
- var pageName = "";
- for (var i = 3; i < tmpArr.length - 3; i++) {
- pageName += tmpArr[i];
- if (i < tmpArr.length - 4) pageName += ",";
- }
- return pageName;
- }
-
- /**
- * Get the date of the last modification of the site.
- *
- * @return the corresponding Date object
- **/
- method.getLastModificationDate = function () {
- var infoStr = this.getSiteInformation();
- var tmpArr = infoStr.split(",");
- var modifDate = new Date(tmpArr[tmpArr.length - 3] * 1000);
- return modifDate;
- }
-
- /**
- * Get the date of the last publish.
- *
- * @return the corresponding Date object
- **/
- method.getLastPublishDate = function () {
- var infoStr = this.getSiteInformation();
- var tmpArr = infoStr.split(",");
- //var pubDateStr = "" + tmpArr[tmpArr.length - 2];
- //var pubDate = new Date(parseInt(pubDateStr + "000"));
- var pubDate = new Date(tmpArr[tmpArr.length - 2] * 1000);
- return pubDate;
- }
-
- /**
- * Get the number of pages in the site.
- *
- * @return number of pages.
- **/
- method.getNumberOfPages = function () {
- var infoStr = this.getSiteInformation();
- return infoStr.substring(infoStr.lastIndexOf(",") + 1);
- }
-
- method.getSiteInformation = function () {
- return NOF.App.getFSIApp2().GetSiteInformation();
- }
-
- /**
- * Get the home page in the site.
- *
- * @return the home page. If no site is open this function will return null.
- **/
- method.getHomePage = function () {
- return this.getCurrentPage().getRootPage();
- }
-
- /**
- * Get the page currently open in the site.
- *
- * @return the current page. If no site is open this function will return null, otherwise the current node is always defined
- **/
- method.getCurrentPage = function () {
- var cPage = new NOF.Page();
- cPage.fsiNode = NOF.App.getFSIApp().GetCurrentNode();
- return cPage;
- }
-
- /**
- * Defines the current page in Fusion. If this function is used in conjunction with
- * setCurrentView(1) you will open a specific page in the Page Design view.
- *
- * @param currentPage the NOF.Page object to be set as current page
- **/
- method.setCurrentPage = function (/*NOF.Page*/ currentPage) {
- NOF.App.getFSIApp().SetCurrentNode(currentPage.fsiNode);
- }
-
- /**
- * Loads a page from its unique number.
- *
- * @return true if the page is loaded.
- **/
- method.loadPageById = function (/*int*/ pageId ) {
- var node = new ActiveXObject(NOF.ProgId.FSINode);
- var s = node.LoadByNumber(pageId);
- node = null;
- return s;
- }
-
- /**
- * Import a new section in a site from a given location.
- *
- * @param parent the NOF.Page object to be set as parent page of the new section
- * @param fromPath
- **/
- method.importSiteSection = function (/*NOF.Page*/ parent,/*String*/ fromPath) {
- //TODO: implement using FSIImporter
- throw new NOF.UTIL.Exception("method not implemented!");
- }
-
- /**
- * SetStyle sets the current style for the current site.
- * The specified style must exist in the site.
- * @param styleName the name of the local style
- * @return true if the operation is successful.
- **/
- method.setCurrentStyle = function (/*String*/ styleName ) {
- return NOF.App.getFSIApp().SetStyle(styleName);
- }
- }
-
- //NOF_Site_ProtoBuilder();
- NOF.__proto__.Site = NOF_Site;
- }